package com.student.wym.mapper;

import com.student.wym.po.Question;
import com.student.wym.vo.UpdateRequestVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface QuestionMapper {

    @Select("select count(*) from ks_question q where q.type = 1")
    Integer findRadioNum();

    @Select("select count(*) from ks_question q where q.type = 2")
    Integer findCheckNum();

    @Select("select count(*) from ks_question q where q.type = 3")
    Integer findJudgeNum();

    @Select("select * from ks_question")
    List<Question> findAll();

    void addAll(List<Question> questions);

    @Insert("insert into ks_question(intro,option_a,option_b,option_c,option_d,result,create_time,type,state) values(#{intro},#{optionA},#{optionB},#{optionC},#{optionD},#{result},#{createTime},#{type},#{state})")
    void insert(Question question);

    @Delete("delete from ks_question")
    void deleteAll();

    @Update("update ks_question set state = #{questionState} where id = #{id}")
    void update(UpdateRequestVo vo);

    @Select("select * from ks_question ksq where ksq.id = #{id}")
    Question findById(Integer id);

}
